$mat-chip-vertical-padding: 8px;
$mat-chip-horizontal-padding: 12px;

$mat-chips-chip-margin: $mat-chip-horizontal-padding / 4;

.mat-chip-list-wrapper {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-start;
}

.mat-chip:not(.mat-basic-chip) {
  display: inline-block;
  padding: $mat-chip-vertical-padding $mat-chip-horizontal-padding $mat-chip-vertical-padding $mat-chip-horizontal-padding;
  border-radius: $mat-chip-horizontal-padding * 2;

  // Apply a margin to adjacent sibling chips.
  & + & {
    margin: 0 0 0 $mat-chips-chip-margin;

    [dir='rtl'] & {
      margin: 0 $mat-chips-chip-margin 0 0;
    }
  }
}

.mat-chip-list-stacked .mat-chip-list-wrapper {
  display: block;

  .mat-chip:not(.mat-basic-chip) {
    display: block;
    margin: 0;
    margin-bottom: $mat-chip-vertical-padding;

    [dir='rtl'] & {
      margin: 0;
      margin-bottom: $mat-chip-vertical-padding;
    }

    &:last-child, [dir='rtl'] &:last-child {
      margin-bottom: 0;
    }
  }
}
